﻿using System;

namespace _15.SieveOfEratosthenes
{
    class SieveOfEratosthenes
    {
        static void Main()
        {
            int[] arr = new int[10000];
            bool prime = true;
            for (int i = 0; i < arr.Length; i++)
            {
                arr[i] = i + 1;
            }
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] == 0)
                {
                    continue;
                }
                else
                {
                    for (int j = 2; j <= Math.Sqrt(arr[i]); j++)
                    {
                        if (arr[i] % j == 0)
                        {
                            prime = false;
                        }
                    }
                }
                if (prime == true)
                {
                    int number = arr[i];
                    for (int g = i + number; g <= arr.Length - 1; g += number)
                    {
                         arr[g] = 0;
                    }
                }

            }
            for (int i = 1; i < arr.Length; i++)
            {
                if (arr[i] != 0)
                {
                    Console.Write(arr[i] + " ");
                }
            }
        }
    }
}
